package com.xbts.screen.controller.workshop;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.IFinalInspectionService;
import com.xbts.screen.service.IMaterialQualityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 终检车间Controller
 */
@Api(tags = "终检车间")
@RestController
@RequestMapping("/finalInspection")
public class FinalInspectionController extends BaseController {


    @Autowired
    private IFinalInspectionService finalInspectionService;
    @Autowired
    private IMaterialQualityService materialQualityService;

    /**
     * 实时达成率
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:finalInspection:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = finalInspectionService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:finalInspection:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = finalInspectionService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:finalInspection:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = finalInspectionService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:finalInspection:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = finalInspectionService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:finalInspection:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = finalInspectionService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:finalInspection:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = finalInspectionService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:finalInspection:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = finalInspectionService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:finalInspection:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = finalInspectionService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 抽检合格率
     */
    @ApiOperation("抽检合格率")
    @RequiresPermissions("workshop:finalInspection:samplingPassRate")
    @GetMapping("/samplingPassRate")
    public AjaxResult samplingPassRate(){
//        SamplingPassRateTrendVO vo = finalInspectionService.samplingPassRate();
//        SamplingPassRateVO vo = finalInspectionService.samplingPassRate();
        SamplingPassRateTrendVO vo = materialQualityService.materialTypeSampling();
        return success(vo);
    }
    /**
     * 抽检合格率趋势
     */


    @ApiOperation("抽检合格率趋势")
    @RequiresPermissions("workshop:finalInspection:samplingPassRateTrend")
    @GetMapping("/samplingPassRateTrend")
    public AjaxResult samplingPassRateTrend(){
        BaseHistogramResult result = finalInspectionService.samplingPassRateTrend();
        return success(result);
    }
    /**
     * 抽检不良统计
     */
    @ApiOperation("抽检不良统计")
    @RequiresPermissions("workshop:finalInspection:samplingBadStatistics")
    @GetMapping("/samplingBadStatistics")
    public AjaxResult samplingBadStatistics(){
        List<BasePieChartResult> resultList = finalInspectionService.samplingBadStatistics();
        return success(resultList);
    }
    /**
     * 全检合格率
     */
    @ApiOperation("全检合格率")
    @RequiresPermissions("workshop:finalInspection:inspectionPassRate")
    @GetMapping("/inspectionPassRate")
    public AjaxResult inspectionPassRate(){
        PassRateVO vo = finalInspectionService.inspectionPassRate();
        return success(vo);
    }
    /**
     * 全检合格率趋势
     */
    @ApiOperation("全检合格率趋势")
    @RequiresPermissions("workshop:finalInspection:inspectionPassRateTrend")
    @GetMapping("/inspectionPassRateTrend")
    public AjaxResult inspectionPassRateTrend(){
        BaseHistogramResult result = finalInspectionService.inspectionPassRateTrend();
        return success(result);
    }
    /**
     * 全检不良统计
     */
    @ApiOperation("全检不良统计")
    @RequiresPermissions("workshop:finalInspection:inspectionBadStatistics")
    @GetMapping("/inspectionBadStatistics")
    public AjaxResult inspectionBadStatistics(){
        List<BasePieChartResult> resultList = finalInspectionService.inspectionBadStatistics();
        return success(resultList);
    }
    /**
     * PCS_报废合格率
     */
    @ApiOperation("PCS_报废合格率")
    @RequiresPermissions("workshop:finalInspection:scrapPassRate")
    @GetMapping("/PCS/scrapPassRate")
    public AjaxResult PCS_scrapPassRate(){
        ScrapRateVO vo = finalInspectionService.PCS_scrapPassRate();
        return success(vo);
    }
    /**
     * PCS_报废统计
     */
    @ApiOperation("PCS_报废统计")
    @RequiresPermissions("workshop:finalInspection:scrapStatistics")
    @GetMapping("/PCS/scrapStatistics")
    public AjaxResult PCS_scrapStatistics(){
        List<BasePieChartResult> resultList = finalInspectionService.PCS_scrapStatistics();
        return success(resultList);
    }
    /**
     * 料号批次合格率记录
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:finalInspection:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = finalInspectionService.passRateRecord();
        return success(resultList);
    }

}
